﻿using Sunny.UI;

namespace CoreShop.App
{
    public partial class FPrinterManage : UIPage
    {
        public FPrinterManage()
        {
            InitializeComponent();
        }

        private void FPrinterManage_Shown(object sender, System.EventArgs e)
        {
            UIPrinterItem item = new UIPrinterItem();
            item.PrinterName = "USB打印机";
            item.Desc1 = "USB打印机/美团/80mm";
            item.Desc2 = "收银：收银打印配置";
            item.ShowLogo = true;
            item.IP = "";
            item.Linked = true;
            item.Image = CoreShop.App.Properties.Resources.p1;
            item.ShowEditNetwork = false;
            item.EditNetwork += Item_EditNetwork;
            item.ClickOperation += Item_ClickOperation;
            item.PrintTestPage += Item_PrintTestPage;
            uiFlowLayoutPanel2.Add(item);

            item = new UIPrinterItem();
            item.PrinterName = "烧腊";
            item.Desc1 = "网口打印机/通用/80mm";
            item.Desc2 = "后厨：烧腊";
            item.ShowLogo = false;
            item.IP = "IP: 192.168.1.241";
            item.Linked = false;
            item.ShowEditNetwork = true;
            item.Image = CoreShop.App.Properties.Resources.p2;
            item.EditNetwork += Item_EditNetwork;
            item.ClickOperation += Item_ClickOperation;
            item.PrintTestPage += Item_PrintTestPage;
            uiFlowLayoutPanel2.Add(item);

            item = new UIPrinterItem();
            item.PrinterName = "点心";
            item.Desc1 = "网口打印机/通用/80mm";
            item.Desc2 = "后厨：油茶酿菜，早茶点心";
            item.ShowLogo = false;
            item.IP = "IP: 192.168.1.253";
            item.Linked = false;
            item.ShowEditNetwork = true;
            item.Image = CoreShop.App.Properties.Resources.p2;
            item.EditNetwork += Item_EditNetwork;
            item.ClickOperation += Item_ClickOperation;
            item.PrintTestPage += Item_PrintTestPage;
            uiFlowLayoutPanel2.Add(item);

            item = new UIPrinterItem();
            item.PrinterName = "中厨";
            item.Desc1 = "网口打印机/通用/80mm";
            item.Desc2 = "后厨：中厨";
            item.ShowLogo = false;
            item.IP = "IP: 192.168.1.246";
            item.Linked = false;
            item.ShowEditNetwork = true;
            item.Image = CoreShop.App.Properties.Resources.p2;
            item.EditNetwork += Item_EditNetwork;
            item.ClickOperation += Item_ClickOperation;
            item.PrintTestPage += Item_PrintTestPage;
            uiFlowLayoutPanel2.Add(item);

            var add = new UIAddPrinter();
            add.AddPrinter += Add_AddPrinter;
            uiFlowLayoutPanel2.Add(add);
        }

        private void Add_AddPrinter(object sender, System.EventArgs e)
        {
            ShowInfoTip("添加打印机");
        }

        private void Item_PrintTestPage(object sender, System.EventArgs e)
        {
            var item = (UIPrinterItem)sender;
            ShowInfoTip(item.PrinterName + ", 打印测试单");
        }

        private void Item_ClickOperation(object sender, System.EventArgs e)
        {
            var item = (UIPrinterItem)sender;
            ShowInfoTip(item.PrinterName + ", 点击操作");
        }

        private void Item_EditNetwork(object sender, System.EventArgs e)
        {
            var item = (UIPrinterItem)sender;
            ShowInfoTip(item.PrinterName + ", 修改网段");
        }
    }
}
